package com.qingke.memo;

import com.qingke.Command.Command;
import com.qingke.Command.CommandFactory.CommandCode;
import com.qingke.Command.UserCommandFactory;

public class MemoApp{
	
    public static void main( String[] args ){
    	
    	System.out.println( "欢迎来到备忘录！" );
    	System.out.println( "输入你所需要的服务或者输入Help了解服务" );
    	CommandCode cmdcode = null;
    	
    	while(true){
    		String cmd = MemoConsole.askUserInput("cmd >");
    		try {
    			cmdcode = CommandCode.valueOf(cmd.toUpperCase());
    		} catch (Exception e) {
    			MemoConsole.println("你输入了一个不合法的命令，请使用 Help 查看帮助");
    			continue;
    		}
    		UserCommandFactory factory = new UserCommandFactory();
    		Command command = factory.buildCommand(cmdcode);
    		command.execute();
    	}
    }
}
